package com.liugl.activitytest

import android.content.Context
import android.content.Intent
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_second.*
import utils.L

class SecondActivity : BasicActivity() {
    companion object {
        fun actionStart(context: Context, data1: String, data2: String) {

            val intent = Intent(context, SecondActivity::class.java).apply {
                putExtra("param1", data1)
                putExtra("param2", data2)

            }
            
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)

        L.d("S TASK ID $taskId")

        val data = intent.getStringExtra("param1")
        val data2 = intent.getStringExtra("param2")

        L.d("data1:$data======data2:$data2")

        start1.setOnClickListener {
            val intent = Intent(this, FirstActivity::class.java)
            startActivity(intent)
        }

        back.setOnClickListener {
            val intent = Intent()
            intent.putExtra("data_return", "Second Result")
            setResult(RESULT_OK, intent)
            finish()
        }

        goto_third.setOnClickListener {
            val intent = Intent(this, ThirdActivity::class.java)
            startActivity(intent)
        }
    }

//    override fun onBackPressed() {
//        val intent = Intent()
//        intent.putExtra("data_return", "Second Result")
//        setResult(RESULT_OK, intent)
//
//        super.onBackPressed()
//    }

    override fun onDestroy() {
        super.onDestroy()
        L.d("SecondActivity destroy")
    }
}